Page({
  data: {
    formData: {} // 存储从发布页传递的表单数据（含金额）
  },

  onLoad() {
    const formData = wx.getStorageSync('formData');
    if (!formData || !formData.title) {
      wx.showToast({ title: '请先填写服务信息', icon: 'none' });
      setTimeout(() => {
        wx.navigateBack({ delta: 1 }); 
      }, 1500);
      return;
    }
    this.setData({ formData });
  },

  handlePay() {
    const { totalAmount } = this.data.formData;
    if (!totalAmount || totalAmount <= 0) {
      wx.showToast({ 
        title: '金额异常，请返回重新填写', 
        icon: 'none' 
      });
      return;
    }
    wx.showLoading({ 
      title: '支付中...', 
      mask: true 
    });
    setTimeout(() => {
      wx.hideLoading();
      wx.showToast({
        title: '支付成功',
        icon: 'success',
        duration: 1500,
        mask: true,
        success: () => {
          setTimeout(() => {
            
            wx.navigateTo({ 
              url: '/pages/completed/completed' 
            });
            wx.removeStorageSync('formData');
          }, 1500);
        }
      });
    }, 2000);
  },

  onBackTap() {
    wx.navigateBack();
  }

  
 
});